/*
* @Author: zhanghang
* @Date:   2018-06-20 14:19:12
* @Last Modified by:   zhanghang
* @Last Modified time: 2018-06-20 15:54:46
*/
import Vue from 'vue'

const app = new Vue({
  // el: '#root',
  template: '<div ref="div">{{text}}</div>',
  data: {
    text: 0
  }
  // watch: {
  //   text (newText, oldText) {
  //     console.log(`${newText} : ${oldText}`)
  //   }
  // }
})

app.$mount('#root')

setInterval(() => {
  app.text += 1
}, 1000)

console.log(app.$data)
console.log(app.$props)
console.log(app.$el)
console.log(app.$options)
// app.$options.render = (h) => {
//   return h('div', {}, 'new render function')
// }

console.log(app.$root === app)
// <item><div></div></item>
console.log(app.$children)
console.log(app.$slots)
console.log(app.$scopedSlots)
console.log(app.$refs)
console.log(app.$isServer)

const unWatch = app.$watch('text', (newText, oldText) => {
  console.log(`${newText} : ${oldText}`)
})

unWatch()

// app.$on('test', (a, b) => {
//   console.log(`test emited ${a} ${b}`)
// })

// app.$emit('test', 1, 2)

app.$once('test', (a, b) => {
  console.log(`test emited ${a} ${b}`)
})

setInterval(() => {
  app.$emit('test', 1, 2)
})


app.$forceUpdate()
